package com.yn.xgame.message;

import java.util.function.Consumer;
import java.util.function.Function;

import com.yn.xgame.IServer;

public class SupplyAndSingleConsumeMessage1<T, R> implements IFuncMessage {
	
	private IServer consumeServer;
	private T t;
	private Function<T, R> func;
	private Consumer<R> consumer;
	
	public SupplyAndSingleConsumeMessage1(IServer consumeServer, T t, Function<T, R> func, Consumer<R> consumer) {
		this.consumeServer = consumeServer;
		this.t = t;
		this.func = func;
		this.consumer = consumer;
	}

	@Override
	public void apply() {
		R r = func.apply(t);
		consumeServer.pushMessage(new Func1Message<R>(r, consumer));
	}

}
